// <copyright file="ChartDataHandler.cs" company="YUIAsp.Net">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>raul popescu</author>
// <email>dev@yuiasp.net</email>
// <date>2009-01-30</date>
// <summary>YUIAsp.Net File</summary>

using System;
using System.Web;
using YUIAspNet;

namespace YUIAspNetDemo.Charts
{
    public class ChartDataHandler : IHttpHandler
    {
        #region IHttpHandler Members

        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            LocalDataSource source = new LocalDataSource();
            source.AddColumn("Season");
            source.AddColumn("Voters");
            var rand = new Random((int)DateTime.Now.Ticks);

            source.AddRow("Summer", rand.Next(0, 200));
            source.AddRow("Spring", rand.Next(0, 200));
            source.AddRow("Winter", rand.Next(0, 200));
            source.AddRow("Autumn", rand.Next(0, 200));

            context.Response.Write(source.Serialize());
        }

        #endregion
    }
}
